/**  
 * Project Name:sz-yrp  
 * File Name:TimedTaskConfig.java  
 * Package Name:sz.com.yrp.yangtze.timetask.config  
 * Date:2020年8月28日上午9:54:25  
 * Copyright (c) 2020, mengwangq@isoftstone.com All Rights Reserved.  
 *  
*/  
  
package com.atxiaodei.springcloud.sshtimedtask.config;

import com.atxiaodei.springcloud.sshtimedtask.service.TimedTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**  
 * ClassName:TimedTaskConfig <br/>  
 * Function: TODO ADD FUNCTION. <br/>  
 * Reason:   TODO ADD REASON. <br/>  
 * Date:     2020年8月28日 上午9:54:25 <br/>  
 * @author   wangmeng  
 * @version    
 * @since    JDK 1.8  
 * @see        
 */
@Component
@Slf4j
public class TimedTaskConfig { 
	
	@Resource
	TimedTaskService timedTaskService;
	//“0 15 10 ? * *” 测试 每天上午10:15触发成功
	@Scheduled(cron="0 0 24 * * ?")
	public void clearLinuxProcess(){
		log.info("获取远程服务器进程号开始："+new Date());
		String proceStr=timedTaskService.execGrepResult();
//		String pro[]=proceStr.split(" ");
		log.info("执行远程服务器结束掉进程 kill -9 "+proceStr);
		timedTaskService.execKileProcess(proceStr);
	}

}
  
